package tmt.usercenter.web.domain.enums;

import com.tmt.annotation.EnumDescriptor;
import com.tmt.annotation.parser.EnumAnnotationParser;
import lombok.Getter;

/**
 * 系统内所有权限
 * Created by Stark on 2017/3/10.
 */
@Getter
public enum AuthorityItem {

	@EnumDescriptor(title = "用户管理", description = "管理帐号信息")
	Manager_Personal(AuthorityType.COMMON, OperationType.MENU, "", " ADMIN REAL_NAME ", "", 0),

		@EnumDescriptor(title = "用户列表", description = "允许浏览客户系统的用户")
		List_Users( AuthorityType.COMMON, OperationType.MENU, Manager_Personal.name(), " ADMIN ", "/admin/user/index", 1),

		@EnumDescriptor(title = "实名认证", description = "实名认证列表")
		List_Real_Name_Material( AuthorityType.COMMON, OperationType.MENU, Manager_Personal.name(), " ADMIN REAL_NAME ", "/admin/realname/index", 2),


	@EnumDescriptor(title = "应用管理", description = "管理第三方应用信息")
	Manager_APP(AuthorityType.COMMON, OperationType.MENU, "", " ADMIN ", "", 1),

		@EnumDescriptor(title = "客户列表", description = "允许浏览用户的客户系统列表")
		List_Clients(AuthorityType.COMMON, OperationType.MENU, Manager_APP.name(), " ADMIN ", "/admin/client/index", 1),

		@EnumDescriptor(title = "角色列表", description = "允许浏览客户系统的角色列表")
		List_Client_Roles(AuthorityType.COMMON, OperationType.MENU, Manager_APP.name(), " ADMIN ", "/admin/role/index", 2),

		@EnumDescriptor(title = "权限列表", description = "允许浏览用户客户系统的权限列表")
		List_Client_Authorities(AuthorityType.COMMON, OperationType.MENU, Manager_APP.name(), " ADMIN ", "/admin/authority/index", 3),

		@EnumDescriptor(title = "注册控制", description = "管理用户注册时的必填字段")
		Client_Login_Control(AuthorityType.COMMON, OperationType.MENU, Manager_APP.name(), " ADMIN ", "/admin/userinfoconfig/index", 4),

		@EnumDescriptor(title = "授权范围", description = "管理可授权的资源范围")
		Auth_Scope_List(AuthorityType.COMMON, OperationType.MENU, Manager_APP.name(), " ADMIN ", "/admin/authscope/index", 5),

		@EnumDescriptor(title = "授权资源", description = "管理可授权访问的资源")
		Auth_Resource_List(AuthorityType.COMMON, OperationType.MENU, Manager_APP.name(), " ADMIN ", "/admin/authresource/index", 6),


	@EnumDescriptor(title = "创建用户", description = "允许创建客户系统的用户")
	Create_User(AuthorityType.SYSTEM, OperationType.ACTION, "", " ADMIN ", "", 2),

	@EnumDescriptor(title = "修改用户", description = "允许修改客户系统的用户")
	Modify_User(AuthorityType.SYSTEM, OperationType.ACTION, "", " ADMIN ", "", 3),

	@EnumDescriptor(title = "删除用户", description = "允许删除客户系统的用户")
	Delete_User(AuthorityType.SYSTEM, OperationType.ACTION, "", " ADMIN ", "", 4),


	@EnumDescriptor(title = "创建客户系统", description = "允许创建客户系统")
	Create_Client(AuthorityType.SYSTEM, OperationType.ACTION, "", " ADMIN ", "", 5),

	@EnumDescriptor(title = "修改客户系统", description = "允许修改客户系统基本信息")
	Modify_Client(AuthorityType.SYSTEM, OperationType.ACTION, "", " ADMIN ", "", 6),

	@EnumDescriptor(title = "删除客户系统", description = "允许删除客户系统基本信息")
	Delete_Client(AuthorityType.SYSTEM, OperationType.ACTION, "",  " ADMIN ", "", 7),


	@EnumDescriptor(title = "创建角色", description = "允许创建客户系统的角色")
	Create_Client_Role(AuthorityType.SYSTEM, OperationType.ACTION, "", " ADMIN ", "", 8),

	@EnumDescriptor(title = "修改角色", description = "允许修改客户角色信息")
	Modify_Client_Role(AuthorityType.SYSTEM, OperationType.ACTION, "", " ADMIN ", "", 9),

	@EnumDescriptor(title = "删除角色", description = "允许删除客户系统的角色")
	Delete_Client_Role(AuthorityType.SYSTEM, OperationType.ACTION, "",  " ADMIN ", "", 10),


	@EnumDescriptor(title = "创建权限", description = "允许创建客户系统的权限")
	Create_Client_Authority(AuthorityType.SYSTEM, OperationType.ACTION, "",  " ADMIN ", "", 12),

	@EnumDescriptor(title = "修改权限", description = "允许修改客户权限信息")
	Modify_Client_Authority(AuthorityType.SYSTEM, OperationType.ACTION, "",  " ADMIN ", "", 13),

	@EnumDescriptor(title = "删除权限", description = "允许删除客户系统的权限")
	Delete_Client_Authority(AuthorityType.SYSTEM, OperationType.ACTION, "",  " ADMIN ", "", 14),


	@EnumDescriptor(title = "客户数据交叉访问", description = "允许跨用户访问其他用户的数据")
	Client_Data_Across_Access(AuthorityType.COMMON, OperationType.ACTION, "",  " ADMIN ", "", 15),

	@EnumDescriptor(title = "全局数据交叉访问", description = "允许跨系统访问其他客户系统的数据")
	System_Data_Across_Access(AuthorityType.SYSTEM, OperationType.ACTION, "", " SUPER_ADMIN REAL_NAME ", "", 16),


	//**********************************前端用户界面菜单权限*******************************************/

	@EnumDescriptor(title = "基本信息", description = "管理用户基本信息")
	Front_Base_Info( AuthorityType.SYSTEM, OperationType.MENU, "", " FRONT ", "/information", 0),

	@EnumDescriptor(title = "联系方式", description = "管理用户联系方式")
	Front_Contact_Info(AuthorityType.SYSTEM, OperationType.MENU, "", " FRONT ", "/contact",  1),

	@EnumDescriptor(title = "账号安全", description = "修改帐号密码")
	Front_Password_Info(AuthorityType.SYSTEM, OperationType.MENU, "", " FRONT ", "/safety",  2),

	@EnumDescriptor(title = "授权管理", description = "历史授权记录列表")
	Front_Grant_History(AuthorityType.SYSTEM, OperationType.MENU, "", " FRONT ", "/grant", 3),

	@EnumDescriptor(title = "登录历史", description = "用户登录记录列表")
	Front_Login_History(AuthorityType.SYSTEM, OperationType.MENU, "", " FRONT ", "/history", 4);

	/*@EnumDescriptor(title = "客户系统", description = "管理用户注册的客户系统")
	Front_Client_List(AuthorityType.SYSTEM, OperationType.MENU, "", " FRONT ", "/client", 5);*/



	private String clientTag;

	private String accessPoint;

	private OperationType operationType;

	private AuthorityType authorityType;

	private String parent;

	private int sort;

	AuthorityItem(AuthorityType authorityType, OperationType operationType,
				  String parent, String clientTag, String accessPoint, int sort){
		this.parent = parent;
		this.sort = sort;
		this.clientTag = clientTag;
		this.accessPoint = accessPoint;
		this.operationType = operationType;
		this.authorityType = authorityType;
	}

	public static AuthorityItem from(String title) {
		return EnumAnnotationParser.convertFromTitle(AuthorityItem.class, title);
	}
}
